// VBConversions Note: VB project level imports
using System.Data;
using DevExpress.XtraEditors.Controls;
using System.Diagnostics;
using System.Xml.Linq;
using DevExpress.XtraEditors.Repository;
using System.Collections.Generic;
using System.Data.SqlClient;
using Microsoft.VisualBasic;
using System.Configuration;
using System.Collections;
using DevExpress.XtraEditors;
using System.Data.Sql;
using Microsoft.SqlServer;
using System.Windows.Forms;
using System;
using DevExpress.XtraReports;
using Microsoft.SqlServer.Management.Smo;
using DevExpress;
using System.Linq;
using System.IO;
// End of VB project level imports


namespace SCIEF.SysBFW.CommonExt
{
	public class EventLogExt
	{
		
		public string Source {get; set;}
		public string Log {get; set;}
		
		public EventLogExt(string source, string log)
		{
			this.Source = source;
			this.Log = log;
			CreateEventLog();
		}
		
		public bool CreateEventLog()
		{
			bool exist = default(bool);
			try
			{
				if (!string.IsNullOrWhiteSpace(Source) && !string.IsNullOrWhiteSpace(Log))
				{
					if (!EventLog.SourceExists(Source))
					{
						EventLog.CreateEventSource(Source, Log);
					}
					exist = true;
				}
				else
				{
					exist = false;
				}
			}
			catch (Exception ex)
			{
				throw (ex);
			}
			return exist;
		}
		
		public void WriteToLog(string message, System.Diagnostics.EventLogEntryType type)
		{
			EventLog.WriteEntry(Source, message, type);
		}
		
		public void WriteToLog(string message, System.Diagnostics.EventLogEntryType type, int eventID)
		{
			EventLog.WriteEntry(Source, message, type, eventID);
		}
		
		public void WriteToLog(string message, System.Diagnostics.EventLogEntryType type, int eventID, short category)
		{
			EventLog.WriteEntry(Source, message, type, eventID, category);
		}
		
	}
	
}
